// app.js
import func from "./utils/util"
import { getInfo, checkInfo } from "./utils/request"

App({
  onLaunch() {
    // 登录
    wx.login({
      success: res => {
        // 发送 res.code 到后台换取 openId, sessionKey, unionId
      }
    })
  },
  async setUserInfo() {
    const data = await getInfo()
    if (data.code === '-1' && wx.getStorageSync('sessionid') === '') {
      wx.navigateTo({
        url: "/pages/wechat/index"
      })
      return false
    }
    else {
      return true
    }
  },
  async checkUserInfo() {
    const data = await checkInfo()
    return data.data
  },
  preview(event, arr) {
    let currentUrl = event.currentTarget.dataset.src
    wx.previewImage({
      current: currentUrl, // 当前显示图片的http链接
      urls: arr // 需要预览的图片http链接列表
    })
  },
  baseUrl: 'https://zdhapi.fly-network.com/',
  func: func,
})
